package com.company.common.util;

import java.text.SimpleDateFormat;
import java.util.Random;
import java.util.UUID;

/**
 *
 *  id生成工具类
 */
public class IdUtils {

    /**
     * @param: []
     * @return: java.lang.String
     * @description: 长度40的id
     * @author: YiHaoxing
     * @date: 2018-10-11 9:02
     */
    public static String getUUID40() {
        String uuid = UUID.randomUUID().toString().replace("-", "");
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
        String str = sdf.format(System.currentTimeMillis()).substring(2, 10) + uuid;
        return str;
    }

    /**
     * @param: []
     * @return: java.lang.String
     * @description: uuid, 长度32
     * @author: YiHaoxing
     * @date: 2018-10-11 9:03
     */
    public static String getUUID() {

        String uuid = UUID.randomUUID().toString().replace("-", "");
        return uuid;
    }

    /**
     * @param: []
     * @return: java.lang.Long
     * @description: long id
     * @author: YiHaoxing
     * @date: 2018-10-11 9:03
     */
    public static Long getLongId() {
        Long id = new Random().nextLong();
        return id;
    }
}
